<!DOCTYPE html>
<html  lang="en">
<head>
    <meta charset="utf-8">
<title>Category: ansible - noback</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />



    <meta property="og:type" content="website">
<meta property="og:title" content="noback">
<meta property="og:url" content="http://alpaca-h.gitee.io/categories/blog-back-new/ansible/index.html">
<meta property="og:site_name" content="noback">
<meta property="og:locale" content="en_US">
<meta property="og:image" content="http://alpaca-h.gitee.io/images/og_image.png">
<meta property="article:author" content="Alpaca">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="http://alpaca-h.gitee.io/images/og_image.png">







<link rel="icon" href="/images/favicon.svg">


<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.7.2/css/bulma.css">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.4.1/css/all.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Ubuntu:400,600|Source+Code+Pro">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/highlight.js@9.12.0/styles/androidstudio.css">


    
    
    
    <style>body>.footer,body>.navbar,body>.section{opacity:0}</style>
    

    
    
    
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/lightgallery@1.6.8/dist/css/lightgallery.min.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/justifiedGallery@3.7.0/dist/css/justifiedGallery.min.css">
    

    
    

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/outdatedbrowser@1.1.5/outdatedbrowser/outdatedbrowser.min.css">


    
    
    
    

<link rel="stylesheet" href="/css/back-to-top.css">


    
    

    
    
    
    

    
    
<link rel="stylesheet" href="/css/progressbar.css">
<script src="https://cdn.jsdelivr.net/npm/pace-js@1.0.2/pace.min.js"></script>

    
    
    

    
    
    
        <script async="" src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
    

    


<link rel="stylesheet" href="/css/style.css">
<meta name="generator" content="Hexo 4.2.0"><link rel="alternate" href="/atom.xml" title="noback" type="application/atom+xml">
</head>
<body class="is-3-column">
    <nav class="navbar navbar-main">
    <div class="container">
        <div class="navbar-brand is-flex-center">
            <a class="navbar-item navbar-logo" href="/">
            
                <img src="/images/logo.svg" alt="noback" height="28">
            
            </a>
        </div>
        <div class="navbar-menu">
            
            <div class="navbar-start">
                
                <a class="navbar-item"
                href="/">Home</a>
                
                <a class="navbar-item"
                href="/archives/">Archives</a>
                
                <a class="navbar-item"
                href="/categories/">Categories</a>
                
                <a class="navbar-item"
                href="/tags/">Tags</a>
                
                <a class="navbar-item"
                href="/about/">About</a>
                
            </div>
            
            <div class="navbar-end">
                
                    
                    
                    <a class="navbar-item" target="_blank" title="AlphaLxy GitHub" href="https://www.github.com/AlphaLxy">
                        
                        <i class="fab fa-github"></i>
                        
                    </a>
                    
                
                
                
                <a class="navbar-item search" title="Search" href="javascript:;">
                    <i class="fas fa-search"></i>
                </a>
                
            </div>
        </div>
    </div>
</nav>
    
    <section class="section">
        <div class="container">
            <div class="columns">
                <div class="column is-8-tablet is-8-desktop is-6-widescreen has-order-2 column-main"><div class="card">
    <div class="card-content">
        <nav class="breadcrumb" aria-label="breadcrumbs">
        <ul>
            <li><a href="/categories">Categories</a></li>
            
            <li><a href="/categories/blog-back-new/">blog_back_new</a></li>
            
            <li class="is-active"><a href="#" aria-current="page">ansible</a></li>
        </ul>
        </nav>
    </div>
</div>

    <div class="card">
    
    <div class="card-content article ">
        <h1 class="title is-size-3 is-size-4-mobile has-text-weight-normal">
            
                <a class="has-link-black-ter" href="/2019/12/29/blog_back_new/ansible/ansible%E5%9F%BA%E7%A1%80/"><i class="fas fa-angle-double-right"></i>ansible基础</a>
            
        </h1>
        
        <div class="level article-meta is-size-7 is-uppercase is-mobile is-overflow-x-auto">
            <div class="level-left">
                <time class="level-item has-text-grey" datetime="2019-12-29T12:54:37.000Z"><i class="far fa-calendar-alt">&nbsp;</i>2019-12-29</time>
                
                <time class="level-item has-text-grey is-hidden-mobile" datetime="2019-12-29T12:59:13.819Z"><i class="far fa-calendar-check">&nbsp;</i>2019-12-29</time>
                
                
                <div class="level-item">
                <i class="far fa-folder-open has-text-grey"></i>&nbsp;
                <a class="has-link-grey -link" href="/categories/blog-back-new/">blog_back_new</a>&nbsp;/&nbsp;<a class="has-link-grey -link" href="/categories/blog-back-new/ansible/">ansible</a>
                </div>
                
                
                <span class="level-item has-text-grey">
                    <i class="far fa-clock"></i>&nbsp;
                    
                    
                    22 minutes read (About 3288 words)
                </span>
                
                
            </div>
        </div>
        
        <div class="content">
            <h2 id="主机清单-inventory"><a href="#主机清单-inventory" class="headerlink" title="主机清单 inventory"></a>主机清单 inventory</h2><p>ansible中添加主机清单的几种形式</p>
<ol>
<li><p>直接在命令行中指定ip,-k登陆时指定密码</p>
<pre><code class="bash">ansible 192.168.20.1 -m ping -k
ansible 192.168.20.1,192.168.20.2 -m ping -k</code></pre>
</li>
<li><p>在配置文件中指定  默认文件夹/etc/ansible/hosts</p>
</li>
</ol>
<pre><code class="bash">[name1]
192.168.20.1
[name2]
192.168.20.2
ansible name1 -m ping -k # 指定分组
ansible all -m ping -k # 指定所有</code></pre>
<p><img src="http://img.noback.top/blog/img/20190902/ansible2.png" alt=""><br>由于ansible是通过ssh访问被执行端主机的，因此没有ssh的权限是无法完成任务的，即使这里的命令是ping，但依旧要走ssh的流程<br>这里的ping并不是linux下的ping ,而是ansible工具下面的ping模块</p>
<ol start="3">
<li><p>不使用默认文件下，自定义文件夹</p>
<pre><code class="bash">echo &quot;192.168.20.1&quot;  &gt;&gt; xx
ansible -i xx all -m ping -k</code></pre>
</li>
<li><p>在配置组里面中直接确认登陆用户</p>
<pre><code class="bash">echo &quot;192.168.20.1 ansible_ssh_user=root ansible_ssh_pass=upyun123&quot;
ansible -i xx all -m ping </code></pre>
</li>
</ol>
<hr>
<h2 id="配置文件"><a href="#配置文件" class="headerlink" title="配置文件"></a>配置文件</h2><ol>
<li>local_tmp是本地的执行指令</li>
<li>remote_tmp是远程的执行指令<br>当用户使用ansible控制被控端执行指令的时候，他会先将内容放在local_tmp文件中，然后上传到被控端并生成remote_tmp上执行。执行完成之后会删除这两个tmp文件</li>
<li>library = /usr/share/my_modules/ 库存放地址</li>
<li>forks = 5 默认并发数</li>
<li>sudo_user = root 默认sudo 用户</li>
<li>ask_sudo_pass = True  每次执行ansible是否询问ssh密码</li>
<li>ask_pass = True</li>
<li>remote_port = 22</li>
<li>host_key_checking = False 检查对应服务器的host_key —–&gt;建议取消注释</li>
<li>log_path=/var/log/ansible.log 日志文件 </li>
</ol>
<h2 id="命令"><a href="#命令" class="headerlink" title="命令"></a>命令</h2><h4 id="ansible-doc-说明文档"><a href="#ansible-doc-说明文档" class="headerlink" title="ansible-doc 说明文档"></a>ansible-doc 说明文档</h4><p>ansible-doc [options] [module..]<br>-a 显示所有模块的文档 参数尽量放在单引号里面<br>-l –list 列出可用模块<br>-s –snippet xxx 显示xxx模块的playbook片段</p>
<p>role扩展模块<br>ansible-galaxy专门有一个网站提供不同用户上传的”角色”<br>地址:<a href="https://galaxy.ansible.com/" target="_blank" rel="noopener">https://galaxy.ansible.com/</a></p>
<pre><code class="bash"># 列出所有已安装的galaxy
ansible-galaxy list
# 安装galaxy
ansible-galaxy install xxx
# 删除galaxy
ansible-galaxy remove xxx</code></pre>
<p>role默认安装路径为/etc/ansible/roles/下</p>
<h4 id="ansible"><a href="#ansible" class="headerlink" title="ansible"></a>ansible</h4><p>列出指定组别的host列表<br>ansible appsevr –list-hosts<br>列出所有列表的host<br>ansible all –list-hosts<br>ansible all –list<br>支持通配符匹配host<br>ansible *serv –list<br>多IP批量执行<br>ansible 192.168.0.1,192.168.0.2 -m ping<br>多组别批量执行(逻辑或关系,合并，A和B所有)<br>ansible websevr:appsevr -m ping<br>(逻辑与关系,区分,在A中,也在B中)<br>ansible “websevr:&amp;appsevr” -m ping<br>(逻辑非,在A中不在B中,此处必须要用单引号)<br>ansible ‘websevr:!appsevr’ -m ping </p>
<p>ansible <host-pattern> [-m module_name] [-a args]<br>–version 显示版本<br>-m module 指定模板,默认为command<br>-v 详细过程 -vv -vvv更详细<br>–list –list-hosts 显示主机列表，<br>-k –ask-pass 提示输入ssh连接密码，默认为key验证<br>-K –ask-become-pass 提示输入sudo时的口令<br>-C –check 检查，并不执行<br>-T –timeout=TIMEOUT 执行命令的超时时间,默认为10s<br>-u –user=REMOTE_USER 执行远程执行的用户<br>-b –become 代替旧版的sudo切换 (默认为ansible.cfg里面设置的用户,一般为root)<br>-a 指定参数</p>
<h4 id="ansible-m命令模块"><a href="#ansible-m命令模块" class="headerlink" title="ansible -m命令模块"></a>ansible -m命令模块</h4><h5 id="command"><a href="#command" class="headerlink" title="command"></a>command</h5><p>在command中,我们可以创建文件，但是对于文件的操作,有一个专门的file模块</p>
<pre><code class="bash"># 创建一个文件
ansible -m command -a &#39;mkdir \data&#39;
# 查看文件是否创建成功
ansible -m command -a &#39;ls -al \data&#39;
# 查看command帮助
ansible-doc command</code></pre>
<h5 id="shell"><a href="#shell" class="headerlink" title="shell"></a>shell</h5><p>如果-a 后带的参数中出现 $ &lt; &gt; | ;  &amp; 等字符，command是不支持的，需要用到shell 模块</p>
<pre><code class="bash"># 输出主机名字
ansible 192.168.1.3 -m shell -a &#39;echo $HOSTNAME&#39;  </code></pre>
<h2 id="ansible命令执行流程"><a href="#ansible命令执行流程" class="headerlink" title="ansible命令执行流程"></a>ansible命令执行流程</h2><p>1.加载自己的配置文件 默认为/etc/ansible/ansible.cfg<br>2.加载自己对应的模块文件,如command<br>3.通过ansible将模块或命令生成对应的临时py文件,并将文件传输至远程服务器的对应执行用户$HOME/.ansible/tmp/ansible-tmp-数字/xxx.py文件<br>4.增加文件的执行权限<br>5.执行并返回结果<br>6.删除临时py文件,sleep 0退出<br>执行状态:<br>绿色 执行成功并且不需要做改变的操作<br>黄色 执行成功但是对目标主机做了修改<br>红色 执行失败<br>(颜色内容在/etc/ansible.cfg里面修改)</p>
<p><strong>生成ssh</strong><br>ssh-keygen<br><strong>复制ssh密钥到其他主机</strong><br>ssh-copy-id 主机ip</p>
<hr>
<h2 id="模块"><a href="#模块" class="headerlink" title="模块"></a>模块</h2><p>由于Ansible的模块过多，将近有1378个模块数量,但是每个模块的介绍以及使用方法都存放在/usr/bin/ansible-doc当中</p>
<pre><code class="bash"># 查看当前ansible模块数量
ansible-doc -l | wc -l
# ansible-doc的使用方法
ansible-doc [options] [module..]
-a 显示所有模块的文档 参数尽量放在单引号里面
-l --list 列出可用模块
-s --snippet xxx 显示xxx模块的playbook片段
# 使用-m指定模块，默认为command
ansible -m command</code></pre>
<h3 id="command-1"><a href="#command-1" class="headerlink" title="command"></a>command</h3><p>在command中,我们可以创建文件，但是对于文件的操作,有一个专门的file模块</p>
<pre><code class="bash"># 创建一个文件
ansible -m command -a &#39;mkdir \data&#39;
# 查看文件是否创建成功
ansible -m command -a &#39;ls -al \data&#39;
# 查看command帮助
ansible-doc command</code></pre>
<h3 id="shell-1"><a href="#shell-1" class="headerlink" title="shell"></a>shell</h3><p>如果-a 后带的参数中出现 $ &lt; &gt; | ;  &amp; 等字符，command是不支持的，需要用到shell 模块</p>
<pre><code class="bash"># 输出主机名字
ansible 192.168.1.3 -m shell -a &#39;echo $HOSTNAME&#39;  </code></pre>
<h3 id="script"><a href="#script" class="headerlink" title="script"></a>script</h3><p>既然ansible可以对多台主机进行批量的操作，那往往我们会遇到一个场景，即需要我们在多台主机上执行一个脚本，这个场景下我们有两个方法:<br>1.将脚本文件复制到多台主机上后,调用ansible使用<br>2.使用script模块，仅在控制端存在脚本文件即可</p>
<pre><code class="bash"># 方法一,先将文件发到对应控制端主机
ansible 192.168.1.3 -m command -a &#39;/root/ansible_test.sh&#39;
# 方法二
root@DESKTOP-GT1K5L0:~# ansible 192.168.1.3 -m script -a &#39;/root/ansible_test.sh&#39;
192.168.1.3 | SUCCESS =&gt; {
    &quot;changed&quot;: true,
    &quot;rc&quot;: 0,
    &quot;stderr&quot;: &quot;Shared connection to 192.168.1.3 closed&quot;,
    &quot;stdout&quot;: &quot;to do it,ansible&quot;,
    &quot;stdout_lines&quot;: [
        &quot;to do it,ansible&quot;
    ]
} </code></pre>
<h3 id="Copy"><a href="#Copy" class="headerlink" title="Copy"></a>Copy</h3><p>在上面我们提到了从控制端传输文件到被控端,既然是批量的操作,那么在ansible中同样存在一个copy的模块,可以用来传输文件<br>场景: 关闭多台主机的selinux<br>流程: 复制控制端selinux的配置文件，修改后发送到被控制端</p>
<p>注意:这里的ho表示的是一个主机群 在/etc/ansible/hosts中已经添加了</p>
<pre><code class="bash"># 查看控制端selinux状态
getenforce

# 查看被控端selinux状态
[root@localhost ~]# ansible ho -m command -a &#39;getenforce&#39;
192.168.1.6 | SUCCESS | rc=0 &gt;&gt;
Enforcing
192.168.1.7 | SUCCESS | rc=0 &gt;&gt;
Enforcing
192.168.1.5 | SUCCESS | rc=0 &gt;&gt;
Enforcing
192.168.1.4 | SUCCESS | rc=0 &gt;&gt;
Enforcing

# 复制selinux配置文件，并修改配置
cp /etc/selinux/config  .
SELINUX=disabled

# 复制配置文件到被控端指定路径,并做好备份
ansible ho -m copy -a&#39;src=/root/hzj/config dest=/etc/selinux/config backup=yes&#39;

# 查看被控端是否生成备份文件
ansible ho -m command -a &#39;ls /etc/selinux/&#39;

# 重启
ansible ho -m command -a &#39;reboot&#39;
# 查看被控端selinux是否修改完成
ansible ho -m command -a &#39;getenforce&#39;
[root@localhost hzj]# ansible ho -m command -a &#39;getenforce&#39;
192.168.1.7 | SUCCESS | rc=0 &gt;&gt;
Disabled
192.168.1.4 | SUCCESS | rc=0 &gt;&gt;
Disabled
192.168.1.5 | SUCCESS | rc=0 &gt;&gt;
Disabled
192.168.1.6 | SUCCESS | rc=0 &gt;&gt;
Disabled</code></pre>
<h3 id="fetch"><a href="#fetch" class="headerlink" title="fetch"></a>fetch</h3><p>ansible支持从被控端抓取文件到控制端,抓取后的格式为\example.com\dest<br>src表示抓取路径<br>dest表示存放路径</p>
<pre><code class="bash"># 复制所有主机的日志到控制端
ansible ho -m fetch -a &#39;src=/var/log/messages dest=/root/data&#39;</code></pre>
<p>但是fetch仅支持单个文件的抓取，当我们想要抓取多个日志文件时，可以先进行打包</p>
<h3 id="file"><a href="#file" class="headerlink" title="file"></a>file</h3><p>设置文件的属性</p>
<pre><code class="bash"># 创建文件
ansible ho -m file -a &#39;name=/data/f3 state=touch&#39;
# 删除文件
ansible ho -m file -a &#39;name=/data/f3 state=absent&#39;
# 创建文件夹
ansible ho -m file -a &#39;name=/data/f3 state=directory&#39;
# 删除文件夹
ansible ho -m file -a &#39;name=/data/f3 state=absent&#39;
# 创建软连接
ansible ho -m file -a &#39;src=/root/test name=/data/fq state=link&#39;

# 但是需要注意的是如果你创建了文件f3 当你创建文件夹f3的时候会出现错误</code></pre>
<h3 id="hostname"><a href="#hostname" class="headerlink" title="hostname"></a>hostname</h3><p>修改主机名</p>
<pre><code class="bash">ansible ho -m hostname -a &#39;name=node&#39;
# 重启后生效</code></pre>
<h3 id="cron"><a href="#cron" class="headerlink" title="cron"></a>cron</h3><pre><code class="bash"># 给每台主机添加任务,name为注释
ansible ho -m cron -a &#39;minute=* weekday=1,3,5,7 job=&quot;usr/bin/wall message&quot;  name=test&#39;
# 取消任务
ansible ho -m cron -a &#39;disabled=true job=&quot;usr/bin/wall message&quot; name=test&#39;
# 重新启用
ansible ho -m cron -a &#39;disabled=no job=&quot;usr/bin/wall message&quot; name=test&#39;
# 删除某条任务
ansible ho -m corn -a &#39;jon=&quot;usr/bin/wall message&quot; state=absent&#39;</code></pre>
<h3 id="yum"><a href="#yum" class="headerlink" title="yum"></a>yum</h3><pre><code class="bash"># name指定包  state指定状态
ansible ho -m yum -a &#39;name=httpd state=latest&#39; 安装
ansible ho -m yum -a &#39;name=httpd state=absent&#39; 删除</code></pre>
<h3 id="Service"><a href="#Service" class="headerlink" title="Service"></a>Service</h3><pre><code class="bash"># 关闭服务  name指定服务名称  state指定状态
ansible ho -m service -a &#39;name=httpd state=stopped&#39;
ansible ho -m service -a &#39;name=httpd state=started&#39;
ansible ho -m service -a&#39;name=httpd state=reloaded&#39;
ansible ho -m service -a&#39;name=httpd state=restarted&#39;</code></pre>
<h3 id="User"><a href="#User" class="headerlink" title="User"></a>User</h3><pre><code class="bash">ansible ho -m user -a &#39;name=user comment=&quot;test user&quot; uid=2048 home=/app/user group=root&#39;
ansible ho -m user -a &#39;name=sysuser system=yes home=/app/syseser1&#39;
ansible ho -m user -a &#39;name=user state=absent remove=yes&#39; 删除用户以及家目录等数据</code></pre>
<h2 id="playbook的编写"><a href="#playbook的编写" class="headerlink" title="playbook的编写"></a>playbook的编写</h2><p>随着工作的增加,单条ansible命令(adhoc)已经不能满足我们的需求.于是我们可以把多条ansible命令写入playbook中,让系统根据playbook中的顺序依次执行ansible。我们把它叫做剧本</p>
<h3 id="Playbook的编写方式"><a href="#Playbook的编写方式" class="headerlink" title="Playbook的编写方式"></a>Playbook的编写方式</h3><p>Playbook的编写格式采用的是yaml语言<br>url: <a href="http://www.ruanyifeng.com/blog/2016/07/yaml.html" target="_blank" rel="noopener">http://www.ruanyifeng.com/blog/2016/07/yaml.html</a><br>url2: <a href="https://www.jianshu.com/p/97222440cd08" target="_blank" rel="noopener">https://www.jianshu.com/p/97222440cd08</a><br>urs3: <a href="https://yaml.org/" target="_blank" rel="noopener">https://yaml.org/</a>  多种语言实现yaml</p>
<p>简单的介绍一下yaml语言的使用</p>
<pre><code class="text">1. 在单一档案中,可以用连续的连字符(---)区分多个档案。另外，还有选择性的连续三个点号(...)用来表示档案结尾
2. 次行开始正常写Playbook的内容，一般建议写明该playbook的功能
3. 使用#号注释代码
4. 缩进统一用tab
5. 一个完整的代码块功能最少的元素需要包括name:task
6. 一个name只能包括一个task
7. yaml文件扩展名通常为yml或者yaml
</code></pre>
<p>playbook例子</p>
<pre><code class="bash">---
- hosts: webservers
  vars:
    http_port: 80
    max_clients: 200
  remote_user: root
  tasks:
  - name: ensure apache is at the latest version
    yum: pkg=httpd state=latest
  - name: write the apache config file
    template: src=/srv/httpd.j2 dest=/etc/httpd.conf
    notify:
    - restart apache
  - name: ensure apache is running
    service: name=httpd state=started
  handlers:
    - name: restart apache
      service: name=httpd state=restarted</code></pre>
<p><strong>playbook核心元素</strong></p>
<ul>
<li>Hosts 执行的远程主机列表</li>
<li>Tasks 任务集</li>
<li>Varniables 内置变量或自定义变量在playbook中调用</li>
<li>Templates 模板,可替换模板文件中的变量并实现一些简单逻辑的文件</li>
<li>Handlers 和 notity 结合使用,由特定条件触发的操作，满足条件方才执行,否则不执行</li>
<li>tags 标签  指定某条任务执行,用于选择运行playbook中的部分代码。ansible具有幂等性,因此会自动跳过没有变化的部分，即便如此，有些代码为测试其确实没有发生变化的时间<br>依然会很长。因此可以使用tags跳过一些代码片段。<br>ansible-playbook -t tagsname useradd.yml</li>
</ul>
<p>adhoc 和 playbook 对比</p>
<pre><code class="bash"># adhoc 改变主机名字
ansible ho -m hostname -a &#39;name=xxx&#39;
# playboot 修改主机名字
---
- host: ho
  remote_user: root

  tasks:
  - name: hello
    hostname: name=node</code></pre>
<p>多条adhoc 和playbook对比</p>
<pre><code class="bash"># adhoc 
ansible ho -m file -a &#39;name=/data/newfile state=touch&#39;  # 创建文件
ansible ho -m user -a &#39;name=test2 system=yes shell=/sbin/nologin&#39; # 创建用户
ansible ho -m yum -a &#39;name=httpd&#39; # 安装httpd
ansible ho -m copy -a &#39;src=/var/www/html/index.html dest=/var/www/html&#39; # 复制文件
ansible ho -m service -a &#39;name=httpd state=started enabled=yes&#39; # 启动服务


# playbook
- hosts: ho
  remote_user: root

  tasks:
  - name: create file
    file: name=/data/newfile state=touch
  - name: create user
    file: name=test2 system=yes shell=/sbin/nologin
  - name: install httpd
    yum: name=httpd
  - name: copy file
    copy: src=/var/www/html/index.html dest=/var/www/html
  - name: start service
    service: name=httpd state=started enabled=yes</code></pre>
<p>shell脚本与playbook对比</p>
<pre><code class="bash"># shell脚本

#!/bin/bash
# 安装Apache
yum install --quiet -y httpd
# 复制配置文件
cp /tmp/httpd.conf /etc/httpd/conf/httpd.conf
cp /tmp/vhosts.conf /etc/httpd/conf.d/
# 启动Apache 并设置开机启动
systemctl start httpd.service
chkconfig httpd on

# playbook
---
- host: all
  tasks:
   - name: &quot;安装Apache&quot;
     yum: name=httpd
   - name: &quot;复制配置文件&quot;
     copy: src=/tmp/httpd.conf dest=/etc/httpd/conf/
   - name: &quot;复制文件&quot;
     copy: src=/tmp/vhosts.conf dest=/etc/httpd/conf.d/
   - name: &quot;启动Apache,并设置开机启动&quot;
     service: name=httpd state=started enabled=yes</code></pre>
<h3 id="执行流程"><a href="#执行流程" class="headerlink" title="执行流程"></a>执行流程</h3><p>play的主体部分是task list 。 task list 中的各任务按次序逐个在hosts中指定的所有主机上执行，即在所有主机上完成第一个任务后在开始第二个，在运行自上而下某一个playbook时，如果中途发生错误，所有已执行任务都将回滚，因此，在更正playbook后重新执行一次即可</p>
<p><strong>忽略错误信息</strong></p>
<pre><code class="bash">task:
- name: copy file
  copy: src=/root/file dest=/root/ || /bin/true

# 或者
task:
- name: copy file
  copy: src=/root/file dest=/root/
  ignore_erros: True</code></pre>
<h3 id="playbook运行方式"><a href="#playbook运行方式" class="headerlink" title="playbook运行方式"></a>playbook运行方式</h3><pre><code class="bash">ansible-playbook &lt;xxx.yml&gt; [options]
--check 只检测可能会发生的改变，但不真正执行操作
--list-hosts 列出运行任务的主机
--limit 主机列表 只针对主机列表中的主机执行
-v 显示过程 -vv -vvv显示更详细</code></pre>
<h3 id="Playbook剧本"><a href="#Playbook剧本" class="headerlink" title="Playbook剧本"></a>Playbook剧本</h3><p>ansible-playbook是ansible中的一个工具,存放在/usr/bin/ansible-playbook</p>
<h1 id="其他"><a href="#其他" class="headerlink" title="其他"></a>其他</h1><ul>
<li><p>模块<br><a href="https://www.cnblogs.com/f-ck-need-u/p/7550603.html" target="_blank" rel="noopener">https://www.cnblogs.com/f-ck-need-u/p/7550603.html</a><br><a href="https://docs.ansible.com/ansible/2.6/modules/list_of_all_modules.html" target="_blank" rel="noopener">https://docs.ansible.com/ansible/2.6/modules/list_of_all_modules.html</a></p>
</li>
<li><p>ansible模块开发<br><a href="https://www.jianshu.com/p/f72b79b0d3f9" target="_blank" rel="noopener">https://www.jianshu.com/p/f72b79b0d3f9</a>  </p>
</li>
</ul>

        </div>
        
        
        
        
    </div>
</div>









    <div class="card">
    
    <div class="card-content article ">
        <h1 class="title is-size-3 is-size-4-mobile has-text-weight-normal">
            
                <a class="has-link-black-ter" href="/2019/12/29/blog_back_new/ansible/ansible%E6%89%B9%E9%87%8F%E6%8E%A7%E5%88%B6%E4%BA%A4%E6%8D%A2%E6%9C%BA/"><i class="fas fa-angle-double-right"></i>ansible总结</a>
            
        </h1>
        
        <div class="level article-meta is-size-7 is-uppercase is-mobile is-overflow-x-auto">
            <div class="level-left">
                <time class="level-item has-text-grey" datetime="2019-12-29T12:54:12.000Z"><i class="far fa-calendar-alt">&nbsp;</i>2019-12-29</time>
                
                <time class="level-item has-text-grey is-hidden-mobile" datetime="2019-12-29T12:56:13.070Z"><i class="far fa-calendar-check">&nbsp;</i>2019-12-29</time>
                
                
                <div class="level-item">
                <i class="far fa-folder-open has-text-grey"></i>&nbsp;
                <a class="has-link-grey -link" href="/categories/blog-back-new/">blog_back_new</a>&nbsp;/&nbsp;<a class="has-link-grey -link" href="/categories/blog-back-new/ansible/">ansible</a>
                </div>
                
                
                <span class="level-item has-text-grey">
                    <i class="far fa-clock"></i>&nbsp;
                    
                    
                    2 minutes read (About 233 words)
                </span>
                
                
            </div>
        </div>
        
        <div class="content">
            <h1 id="登陆h3c交换机"><a href="#登陆h3c交换机" class="headerlink" title="登陆h3c交换机"></a>登陆h3c交换机</h1><p>h3c交换机的模块支持度极低，网上大多都是思科交换机的模块，很多要用到H3c的都是自己写的，感觉很坑</p>
<h2 id="问题"><a href="#问题" class="headerlink" title="问题:"></a>问题:</h2><p>现在又一个问题就是命令行使用raw模块可以登陆交换机，并且输出执指令 返回结果，但是在ansible-playbook中不行</p>
<pre><code class="bash">echo &quot;10.0.5.124&quot;  &gt;&gt; ./xx
ansible -i xx all -m raw -a &#39;system-view ;dis arp ;&#39;</code></pre>
<p>如上是可以的，但是如下的playbook则不行</p>
<pre><code class="bash">echo first.yml &lt;&lt; EOF
  ---
  - hosts: switch

    tasks:
    - name: add snmp
      raw: &quot;system-view ;&quot;
EOF

ansible-playbook first.yml</code></pre>
<p>解决办法，既然playbook不行，那就切换成一条一条的命令行把</p>
<pre><code class="bash">echo yy &lt;&lt; EOF
system-view ;
display arp ;
EOF

echo &quot;10.0.5.124 ansible_ssh_user=admin ansible_ssh_pass=upyun123&quot; &gt;&gt; xx
while read cmd;do ansible -i xx -m raw -a &quot;$cmd&quot; -u an -k ;done &lt; yy</code></pre>
<h2 id="other"><a href="#other" class="headerlink" title="other"></a>other</h2><p>python+yaml+jinja2 自动生成华三交换机配置<br><a href="https://www.jianshu.com/p/4937de3070aa" target="_blank" rel="noopener">https://www.jianshu.com/p/4937de3070aa</a></p>

        </div>
        
        
        
        
    </div>
</div>









</div>
                




<div class="column is-4-tablet is-4-desktop is-3-widescreen  has-order-1 column-left ">
    
        
<div class="card widget">
    <div class="card-content">
        <nav class="level" style="margin-bottom:1rem">
            <div class="level-item has-text-centered">
                <div>
                    
                        <img class="image is-96x96 has-mb-6" src="https://www.gravatar.com/avatar/e0f4032c0f2d1068ffffbaf93c0bef52?s=96" alt="Xinyu Liu">
                    
                    
                    <p class="is-size-4 is-block">
                        Xinyu Liu
                    </p>
                    
                    
                    <p class="is-size-6 is-block">
                        Alpha Lxy
                    </p>
                    
                    
                    <p class="is-size-6 is-flex is-flex-center has-text-grey">
                        <i class="fas fa-map-marker-alt has-mr-7"></i>
                        <span>Beijing, China</span>
                    </p>
                    
                </div>
            </div>
        </nav>
        <nav class="level menu-list is-mobile" style="margin-bottom:1rem">
            <div class="level-item has-text-centered is-marginless">
                <a href="/archives/">
                    <p class="heading">
                        Posts
                    </p>
                    <p class="title has-text-weight-normal">
                        40
                    </p>
                </a>
            </div>
            <div class="level-item has-text-centered is-marginless">
                <a href="/categories/">
                    <p class="heading">
                        Categories
                    </p>
                    <p class="title has-text-weight-normal">
                        13
                    </p>
                </a>
            </div>
            <div class="level-item has-text-centered is-marginless">
                <a href="/tags/">
                    <p class="heading">
                        Tags
                    </p>
                    <p class="title has-text-weight-normal">
                        0
                    </p>
                </a>
            </div>
        </nav>
        <div class="level">
            <a class="level-item button is-link is-rounded" href="https://www.github.com/AlphaLxy" target="_blank">
                <i class="fab fa-github"></i>&nbsp;&nbsp;Follow</a>
        </div>
        
        
    </div>
</div>

    
        

    
        


    
        

    
        <div class="card widget is-hidden-mobile">
    <div class="card-content">
        <div class="menu">
        <h3 class="menu-label">
            Archives
        </h3>
        <ul class="menu-list">
        
        <li>
            <a class="level is-marginless" href="/archives/2020/01/">
                <span class="level-start">
                    <span class="level-item">January 2020</span>
                </span>
                <span class="level-end">
                    <span class="level-item tag">8</span>
                </span>
            </a>
        </li>
        
        <li>
            <a class="level is-marginless" href="/archives/2019/12/">
                <span class="level-start">
                    <span class="level-item">December 2019</span>
                </span>
                <span class="level-end">
                    <span class="level-item tag">32</span>
                </span>
            </a>
        </li>
        
        </ul>
        </div>
    </div>
</div>

    
    
        <div class="column-right-shadow is-hidden-widescreen ">
        
            
<div class="card widget">
    <div class="card-content">
        <h3 class="menu-label">
            Recent
        </h3>
        
        <article class="media">
            
            <a href="/2020/01/05/blog_back_new/linux/keepalive+lvs%E5%9B%9B%E5%B1%82%E8%B4%9F%E8%BD%BD%E5%9D%87%E8%A1%A1/" class="media-left">
                <p class="image is-64x64">
                    <img class="thumbnail" src="/images/thumbnail.svg" alt="keepalive+lvs 四层负载均衡">
                </p>
            </a>
            
            <div class="media-content">
                <div class="content">
                    <div><time class="has-text-grey is-size-7 is-uppercase" datetime="2020-01-05T05:06:09.000Z">2020-01-05</time></div>
                    <a href="/2020/01/05/blog_back_new/linux/keepalive+lvs%E5%9B%9B%E5%B1%82%E8%B4%9F%E8%BD%BD%E5%9D%87%E8%A1%A1/" class="has-link-black-ter is-size-6">keepalive+lvs 四层负载均衡</a>
                    <p class="is-size-7 is-uppercase">
                        <a class="has-link-grey -link" href="/categories/blog-back-new/">blog_back_new</a> / <a class="has-link-grey -link" href="/categories/blog-back-new/linux/">linux</a>
                    </p>
                </div>
            </div>
        </article>
        
        <article class="media">
            
            <a href="/2020/01/05/blog_back_new/linux/linux%E7%BD%91%E7%BB%9C%E7%AE%A1%E7%90%86/iptables%E3%80%81firewall%E9%98%B2%E7%81%AB%E5%A2%99/" class="media-left">
                <p class="image is-64x64">
                    <img class="thumbnail" src="/images/thumbnail.svg" alt="iptables、firewall 防火墙">
                </p>
            </a>
            
            <div class="media-content">
                <div class="content">
                    <div><time class="has-text-grey is-size-7 is-uppercase" datetime="2020-01-05T04:03:16.000Z">2020-01-05</time></div>
                    <a href="/2020/01/05/blog_back_new/linux/linux%E7%BD%91%E7%BB%9C%E7%AE%A1%E7%90%86/iptables%E3%80%81firewall%E9%98%B2%E7%81%AB%E5%A2%99/" class="has-link-black-ter is-size-6">iptables、firewall 防火墙</a>
                    <p class="is-size-7 is-uppercase">
                        <a class="has-link-grey -link" href="/categories/blog-back-new/">blog_back_new</a> / <a class="has-link-grey -link" href="/categories/blog-back-new/linux/">linux</a>
                    </p>
                </div>
            </div>
        </article>
        
        <article class="media">
            
            <a href="/2020/01/05/blog_back_new/linux/linux%E7%BD%91%E7%BB%9C%E7%AE%A1%E7%90%86/netstat/" class="media-left">
                <p class="image is-64x64">
                    <img class="thumbnail" src="/images/thumbnail.svg" alt="netstat">
                </p>
            </a>
            
            <div class="media-content">
                <div class="content">
                    <div><time class="has-text-grey is-size-7 is-uppercase" datetime="2020-01-05T03:51:48.000Z">2020-01-05</time></div>
                    <a href="/2020/01/05/blog_back_new/linux/linux%E7%BD%91%E7%BB%9C%E7%AE%A1%E7%90%86/netstat/" class="has-link-black-ter is-size-6">netstat</a>
                    <p class="is-size-7 is-uppercase">
                        <a class="has-link-grey -link" href="/categories/blog-back-new/">blog_back_new</a> / <a class="has-link-grey -link" href="/categories/blog-back-new/linux/">linux</a>
                    </p>
                </div>
            </div>
        </article>
        
        <article class="media">
            
            <a href="/2020/01/04/blog_back_new/%E7%BD%91%E7%BB%9C/%E7%BD%91%E7%BB%9C%E9%83%A8%E7%BD%B2%E9%9C%80%E6%B1%82%E5%88%86%E6%9E%90/" class="media-left">
                <p class="image is-64x64">
                    <img class="thumbnail" src="/images/thumbnail.svg" alt="网络部署需求分析">
                </p>
            </a>
            
            <div class="media-content">
                <div class="content">
                    <div><time class="has-text-grey is-size-7 is-uppercase" datetime="2020-01-04T02:22:09.000Z">2020-01-04</time></div>
                    <a href="/2020/01/04/blog_back_new/%E7%BD%91%E7%BB%9C/%E7%BD%91%E7%BB%9C%E9%83%A8%E7%BD%B2%E9%9C%80%E6%B1%82%E5%88%86%E6%9E%90/" class="has-link-black-ter is-size-6">网络部署需求分析</a>
                    <p class="is-size-7 is-uppercase">
                        <a class="has-link-grey -link" href="/categories/blog-back-new/">blog_back_new</a> / <a class="has-link-grey -link" href="/categories/blog-back-new/%E7%BD%91%E7%BB%9C/">网络</a>
                    </p>
                </div>
            </div>
        </article>
        
        <article class="media">
            
            <a href="/2020/01/03/blog_back_new/linux/httpd%E6%9C%8D%E5%8A%A1/" class="media-left">
                <p class="image is-64x64">
                    <img class="thumbnail" src="/images/thumbnail.svg" alt="httpd服务">
                </p>
            </a>
            
            <div class="media-content">
                <div class="content">
                    <div><time class="has-text-grey is-size-7 is-uppercase" datetime="2020-01-03T09:18:50.000Z">2020-01-03</time></div>
                    <a href="/2020/01/03/blog_back_new/linux/httpd%E6%9C%8D%E5%8A%A1/" class="has-link-black-ter is-size-6">httpd服务</a>
                    <p class="is-size-7 is-uppercase">
                        <a class="has-link-grey -link" href="/categories/blog-back-new/">blog_back_new</a> / <a class="has-link-grey -link" href="/categories/blog-back-new/linux/">linux</a>
                    </p>
                </div>
            </div>
        </article>
        
    </div>
</div>

        
            
<div class="card widget">
    <div class="card-content">
        <div class="menu">
            <h3 class="menu-label">
                Categories
            </h3>
            <ul class="menu-list">
            <li>
        <a class="level is-marginless" href="/categories/blog-back-new/">
            <span class="level-start">
                <span class="level-item">blog_back_new</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">39</span>
            </span>
        </a><ul><li>
        <a class="level is-marginless" href="/categories/blog-back-new/C%E8%AF%AD%E8%A8%80/">
            <span class="level-start">
                <span class="level-item">C语言</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">1</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/Python/">
            <span class="level-start">
                <span class="level-item">Python</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">4</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/Rust/">
            <span class="level-start">
                <span class="level-item">Rust</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">5</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/ansible/">
            <span class="level-start">
                <span class="level-item">ansible</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">2</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/django/">
            <span class="level-start">
                <span class="level-item">django</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">8</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/git/">
            <span class="level-start">
                <span class="level-item">git</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">1</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/linux/">
            <span class="level-start">
                <span class="level-item">linux</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">4</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/mysql/">
            <span class="level-start">
                <span class="level-item">mysql</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">1</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/%E6%89%A9%E5%B1%95/">
            <span class="level-start">
                <span class="level-item">扩展</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">3</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/">
            <span class="level-start">
                <span class="level-item">数据结构</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">1</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/%E7%BD%91%E7%BB%9C/">
            <span class="level-start">
                <span class="level-item">网络</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">3</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/%E8%AE%BE%E5%A4%87/">
            <span class="level-start">
                <span class="level-item">设备</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">6</span>
            </span>
        </a></li></ul></li>
            </ul>
        </div>
    </div>
</div>
        
        </div>
    
</div>

                




<div class="column is-4-tablet is-4-desktop is-3-widescreen is-hidden-touch is-hidden-desktop-only has-order-3 column-right ">
    
        
<div class="card widget">
    <div class="card-content">
        <h3 class="menu-label">
            Recent
        </h3>
        
        <article class="media">
            
            <a href="/2020/01/05/blog_back_new/linux/keepalive+lvs%E5%9B%9B%E5%B1%82%E8%B4%9F%E8%BD%BD%E5%9D%87%E8%A1%A1/" class="media-left">
                <p class="image is-64x64">
                    <img class="thumbnail" src="/images/thumbnail.svg" alt="keepalive+lvs 四层负载均衡">
                </p>
            </a>
            
            <div class="media-content">
                <div class="content">
                    <div><time class="has-text-grey is-size-7 is-uppercase" datetime="2020-01-05T05:06:09.000Z">2020-01-05</time></div>
                    <a href="/2020/01/05/blog_back_new/linux/keepalive+lvs%E5%9B%9B%E5%B1%82%E8%B4%9F%E8%BD%BD%E5%9D%87%E8%A1%A1/" class="has-link-black-ter is-size-6">keepalive+lvs 四层负载均衡</a>
                    <p class="is-size-7 is-uppercase">
                        <a class="has-link-grey -link" href="/categories/blog-back-new/">blog_back_new</a> / <a class="has-link-grey -link" href="/categories/blog-back-new/linux/">linux</a>
                    </p>
                </div>
            </div>
        </article>
        
        <article class="media">
            
            <a href="/2020/01/05/blog_back_new/linux/linux%E7%BD%91%E7%BB%9C%E7%AE%A1%E7%90%86/iptables%E3%80%81firewall%E9%98%B2%E7%81%AB%E5%A2%99/" class="media-left">
                <p class="image is-64x64">
                    <img class="thumbnail" src="/images/thumbnail.svg" alt="iptables、firewall 防火墙">
                </p>
            </a>
            
            <div class="media-content">
                <div class="content">
                    <div><time class="has-text-grey is-size-7 is-uppercase" datetime="2020-01-05T04:03:16.000Z">2020-01-05</time></div>
                    <a href="/2020/01/05/blog_back_new/linux/linux%E7%BD%91%E7%BB%9C%E7%AE%A1%E7%90%86/iptables%E3%80%81firewall%E9%98%B2%E7%81%AB%E5%A2%99/" class="has-link-black-ter is-size-6">iptables、firewall 防火墙</a>
                    <p class="is-size-7 is-uppercase">
                        <a class="has-link-grey -link" href="/categories/blog-back-new/">blog_back_new</a> / <a class="has-link-grey -link" href="/categories/blog-back-new/linux/">linux</a>
                    </p>
                </div>
            </div>
        </article>
        
        <article class="media">
            
            <a href="/2020/01/05/blog_back_new/linux/linux%E7%BD%91%E7%BB%9C%E7%AE%A1%E7%90%86/netstat/" class="media-left">
                <p class="image is-64x64">
                    <img class="thumbnail" src="/images/thumbnail.svg" alt="netstat">
                </p>
            </a>
            
            <div class="media-content">
                <div class="content">
                    <div><time class="has-text-grey is-size-7 is-uppercase" datetime="2020-01-05T03:51:48.000Z">2020-01-05</time></div>
                    <a href="/2020/01/05/blog_back_new/linux/linux%E7%BD%91%E7%BB%9C%E7%AE%A1%E7%90%86/netstat/" class="has-link-black-ter is-size-6">netstat</a>
                    <p class="is-size-7 is-uppercase">
                        <a class="has-link-grey -link" href="/categories/blog-back-new/">blog_back_new</a> / <a class="has-link-grey -link" href="/categories/blog-back-new/linux/">linux</a>
                    </p>
                </div>
            </div>
        </article>
        
        <article class="media">
            
            <a href="/2020/01/04/blog_back_new/%E7%BD%91%E7%BB%9C/%E7%BD%91%E7%BB%9C%E9%83%A8%E7%BD%B2%E9%9C%80%E6%B1%82%E5%88%86%E6%9E%90/" class="media-left">
                <p class="image is-64x64">
                    <img class="thumbnail" src="/images/thumbnail.svg" alt="网络部署需求分析">
                </p>
            </a>
            
            <div class="media-content">
                <div class="content">
                    <div><time class="has-text-grey is-size-7 is-uppercase" datetime="2020-01-04T02:22:09.000Z">2020-01-04</time></div>
                    <a href="/2020/01/04/blog_back_new/%E7%BD%91%E7%BB%9C/%E7%BD%91%E7%BB%9C%E9%83%A8%E7%BD%B2%E9%9C%80%E6%B1%82%E5%88%86%E6%9E%90/" class="has-link-black-ter is-size-6">网络部署需求分析</a>
                    <p class="is-size-7 is-uppercase">
                        <a class="has-link-grey -link" href="/categories/blog-back-new/">blog_back_new</a> / <a class="has-link-grey -link" href="/categories/blog-back-new/%E7%BD%91%E7%BB%9C/">网络</a>
                    </p>
                </div>
            </div>
        </article>
        
        <article class="media">
            
            <a href="/2020/01/03/blog_back_new/linux/httpd%E6%9C%8D%E5%8A%A1/" class="media-left">
                <p class="image is-64x64">
                    <img class="thumbnail" src="/images/thumbnail.svg" alt="httpd服务">
                </p>
            </a>
            
            <div class="media-content">
                <div class="content">
                    <div><time class="has-text-grey is-size-7 is-uppercase" datetime="2020-01-03T09:18:50.000Z">2020-01-03</time></div>
                    <a href="/2020/01/03/blog_back_new/linux/httpd%E6%9C%8D%E5%8A%A1/" class="has-link-black-ter is-size-6">httpd服务</a>
                    <p class="is-size-7 is-uppercase">
                        <a class="has-link-grey -link" href="/categories/blog-back-new/">blog_back_new</a> / <a class="has-link-grey -link" href="/categories/blog-back-new/linux/">linux</a>
                    </p>
                </div>
            </div>
        </article>
        
    </div>
</div>

    
        
<div class="card widget">
    <div class="card-content">
        <div class="menu">
            <h3 class="menu-label">
                Categories
            </h3>
            <ul class="menu-list">
            <li>
        <a class="level is-marginless" href="/categories/blog-back-new/">
            <span class="level-start">
                <span class="level-item">blog_back_new</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">39</span>
            </span>
        </a><ul><li>
        <a class="level is-marginless" href="/categories/blog-back-new/C%E8%AF%AD%E8%A8%80/">
            <span class="level-start">
                <span class="level-item">C语言</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">1</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/Python/">
            <span class="level-start">
                <span class="level-item">Python</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">4</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/Rust/">
            <span class="level-start">
                <span class="level-item">Rust</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">5</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/ansible/">
            <span class="level-start">
                <span class="level-item">ansible</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">2</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/django/">
            <span class="level-start">
                <span class="level-item">django</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">8</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/git/">
            <span class="level-start">
                <span class="level-item">git</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">1</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/linux/">
            <span class="level-start">
                <span class="level-item">linux</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">4</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/mysql/">
            <span class="level-start">
                <span class="level-item">mysql</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">1</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/%E6%89%A9%E5%B1%95/">
            <span class="level-start">
                <span class="level-item">扩展</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">3</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/">
            <span class="level-start">
                <span class="level-item">数据结构</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">1</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/%E7%BD%91%E7%BB%9C/">
            <span class="level-start">
                <span class="level-item">网络</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">3</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/blog-back-new/%E8%AE%BE%E5%A4%87/">
            <span class="level-start">
                <span class="level-item">设备</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">6</span>
            </span>
        </a></li></ul></li>
            </ul>
        </div>
    </div>
</div>
    
    
</div>

            </div>
        </div>
    </section>
    <footer class="footer">
    <div class="container">
        <div class="level">
            <div class="level-start has-text-centered-mobile">
                <a class="footer-logo is-block has-mb-6" href="/">
                
                    <img src="/images/logo.svg" alt="noback" height="28">
                
                </a>
                <p class="is-size-7">
                &copy; 2020 Alpaca&nbsp;
                Powered by <a href="http://hexo.io/" target="_blank">Hexo</a> & <a
                        href="http://github.com/ppoffice/hexo-theme-icarus" target="_blank">Icarus</a>
                
                <br>
                <span id="busuanzi_container_site_uv">
                Visited by <span id="busuanzi_value_site_uv">0</span> users
                </span>
                
                </p>
            </div>
            <div class="level-end">
            
                <div class="field has-addons is-flex-center-mobile has-mt-5-mobile is-flex-wrap is-flex-middle">
                
                
                <p class="control">
                    <a class="button is-white is-large" target="_blank" title="CC BY-NC-SA 4.0" href="https://creativecommons.org/licenses/by-nc-sa/4.0/">
                        
                        <i class="fab fa-creative-commons"></i>&nbsp;<i class="fab fa-creative-commons-by"></i>&nbsp;<i class="fab fa-creative-commons-nc"></i>&nbsp;<i class="fab fa-creative-commons-sa"></i>&nbsp;
                        
                    </a>
                </p>
                
                <p class="control">
                    <a class="button is-white is-large" target="_blank" title="AlphaLxy GitHub" href="https://www.github.com/AlphaLxy">
                        
                        <i class="fab fa-github"></i>&nbsp;
                        
                    </a>
                </p>
                
                </div>
            
            </div>
        </div>
    </div>
</footer>

    <script src="https://cdn.jsdelivr.net/npm/jquery@3.3.1/dist/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/moment@2.22.2/min/moment-with-locales.min.js"></script>
<script>moment.locale("en");</script>


    
    
    
    <script src="/js/animation.js"></script>
    

    
    
    
    <script src="https://cdn.jsdelivr.net/npm/lightgallery@1.6.8/dist/js/lightgallery.min.js" defer></script>
    <script src="https://cdn.jsdelivr.net/npm/justifiedGallery@3.7.0/dist/js/jquery.justifiedGallery.min.js" defer></script>
    <script src="/js/gallery.js" defer></script>
    

    
    

<div id="outdated">
    <h6>Your browser is out-of-date!</h6>
    <p>Update your browser to view this website correctly. <a id="btnUpdateBrowser" href="http://outdatedbrowser.com/" target="_blank" rel="noopener">Update
            my browser now </a></p>
    <p class="last"><a href="#" id="btnCloseUpdateBrowser" title="Close">&times;</a></p>
</div>
<script src="https://cdn.jsdelivr.net/npm/outdatedbrowser@1.1.5/outdatedbrowser/outdatedbrowser.min.js" defer></script>
<script>
    document.addEventListener("DOMContentLoaded", function () {
        outdatedBrowser({
            bgColor: '#f25648',
            color: '#ffffff',
            lowerThan: 'flex'
        });
    });
</script>


    
    
<script src="https://cdn.jsdelivr.net/npm/mathjax@2.7.5/unpacked/MathJax.js?config=TeX-MML-AM_CHTML" defer></script>
<script>
document.addEventListener('DOMContentLoaded', function () {
    MathJax.Hub.Config({
        'HTML-CSS': {
            matchFontHeight: false
        },
        SVG: {
            matchFontHeight: false
        },
        CommonHTML: {
            matchFontHeight: false
        },
        tex2jax: {
            inlineMath: [
                ['$','$'],
                ['\\(','\\)']
            ]
        }
    });
});
</script>

    
    

<a id="back-to-top" title="Back to Top" href="javascript:;">
    <i class="fas fa-chevron-up"></i>
</a>
<script src="/js/back-to-top.js" defer></script>


    
    

    
    
    
    

    
    
    
    
    
    <script src="https://cdn.jsdelivr.net/npm/clipboard@2.0.4/dist/clipboard.min.js" defer></script>
    <script src="/js/clipboard.js" defer></script>
    

    
    
    

    


<script src="/js/main.js" defer></script>

    
    <div class="searchbox ins-search">
    <div class="searchbox-container ins-search-container">
        <div class="searchbox-input-wrapper">
            <input type="text" class="searchbox-input ins-search-input" placeholder="Type something..." />
            <span class="searchbox-close ins-close ins-selectable"><i class="fa fa-times-circle"></i></span>
        </div>
        <div class="searchbox-result-wrapper ins-section-wrapper">
            <div class="ins-section-container"></div>
        </div>
    </div>
</div>
<script>
    (function (window) {
        var INSIGHT_CONFIG = {
            TRANSLATION: {
                POSTS: 'Posts',
                PAGES: 'Pages',
                CATEGORIES: 'Categories',
                TAGS: 'Tags',
                UNTITLED: '(Untitled)',
            },
            CONTENT_URL: '/content.json',
        };
        window.INSIGHT_CONFIG = INSIGHT_CONFIG;
    })(window);
</script>
<script src="/js/insight.js" defer></script>
<link rel="stylesheet" href="/css/search.css">
<link rel="stylesheet" href="/css/insight.css">
    
</body>
</html>